
//
//  SectionView.m
//  折叠选项卡
//
//  Created by Apple on 2017/7/8.
//  Copyright © 2017年 郭凯. All rights reserved.
//

#import "SectionView.h"
#import "SectionModel.h"
@interface SectionView()
@property (strong, nonatomic) IBOutlet UIImageView *arrowImageView;
@property (strong, nonatomic) IBOutlet UILabel *textView;

@end

@implementation SectionView
-(void)awakeFromNib{
    [super awakeFromNib];
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickSectionView)];
    [self addGestureRecognizer:tap];
}

// 点击组视图
-(void)clickSectionView{
    self.model.isExpand = !self.model.isExpand;
    if (self.model.isExpand) {//展开
        self.arrowImageView.transform = CGAffineTransformIdentity;
    }else{
        self.arrowImageView.transform = CGAffineTransformMakeRotation(M_PI);
    }

    if (self.callBackBlock) {
        self.callBackBlock(self.model.isExpand);
    }
}


-(void)setModel:(SectionModel *)model{

    _model = model;
    self.textView.text = model.title;
    
    if (self.model.isExpand) {//展开
        self.arrowImageView.transform = CGAffineTransformIdentity;
    }else{
        self.arrowImageView.transform = CGAffineTransformMakeRotation(M_PI);
    }
    
}
@end
